//
//  HomePromptRemoveView.m
//  CheekiOS
//
//  Created by mac on 2017/8/10.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HomePromptRemoveView.h"

@interface HomePromptRemoveView ()

@property (nonatomic, strong) UILabel *location;
@property (nonatomic, strong) UIButton *RemoveButton;
@property (nonatomic, strong) UIButton *CancelButton;

@end

@implementation HomePromptRemoveView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        self.backgroundColor = RGB(222, 222, 222);
        [self setUpWaves];
    }
    
    return self;
}
- (void)setUpWaves{
    
    _location = [[UILabel alloc] initWithFrame:CGRectMake(0, 1, KScreenWidth, 50)];
    _location.text = @"清除位置信息后，别人将不能查看到你";
    _location.backgroundColor = [UIColor whiteColor];
    _location.font = FontP(13);
    _location.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_location];
    
    _RemoveButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_RemoveButton setTitle:@"清除位置信息并退出" forState:UIControlStateNormal];
    _RemoveButton.titleLabel.font = FontP(16);
    _RemoveButton.backgroundColor = [UIColor whiteColor];
    _RemoveButton.contentHorizontalAlignment=UIControlContentHorizontalAlignmentCenter;
    [_RemoveButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [_RemoveButton addTarget:self action:@selector(RemoveButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    _RemoveButton.frame = CGRectMake(0, _location.bottom+1, _location.width, _location.height);
    [self addSubview:_RemoveButton];

    
    _CancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_CancelButton setTitle:@"取消" forState:UIControlStateNormal];
    _CancelButton.titleLabel.font = FontP(16);
    _CancelButton.backgroundColor = [UIColor whiteColor];
    _CancelButton.contentHorizontalAlignment=UIControlContentHorizontalAlignmentCenter;
    [_CancelButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [_CancelButton addTarget:self action:@selector(CancelButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    _CancelButton.frame = CGRectMake(0, _RemoveButton.bottom+5, _location.width, _location.height);
    [self addSubview:_CancelButton];
    
}

- (void)RemoveButtonClick:(UIButton *)sender{

    if ([self.delegate respondsToSelector:@selector(RemoveButtonClick:)]) {
        [self.delegate RemoveButtonClick:sender];
    }

}

-(void)CancelButtonClick:(UIButton *)sender{
        CATransition *animation = [CATransition  animation];

        animation.duration = 0.5f;
        animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        animation.type = kCATransitionPush;
        animation.subtype = kCATransitionFromBottom;
        [self.layer addAnimation:animation forKey:@"animtion2"];
        [UIView animateWithDuration:0.5 animations:^{
            self.alpha = 1;
        }completion:^(BOOL finished) {
            [self removeFromSuperview];
        }];

}

@end
